var t = getApp();

Page({
    data: {
        page: 1,
        plugin_name: "问卷调查"
    },
    onLoad: function(t) {
        var a = "";
        wx.getSystemInfo({
            success: function(t) {
                console.log(t.statusBarHeight), a = 2 * t.statusBarHeight + 20;
            }
        }), this.setData({
            statusBarHeight: a
        }), this.getData();
    },
    detail: function(t) {
        var a = t.currentTarget.dataset.item;
        if ("ios" == wx.getSystemInfoSync().platform && (a.start_time = a.start_time.replace(/\./g, "/"), 
        a.end_time = a.end_time.replace(/\./g, "/")), a.start_time && a.end_time) {
            var e = Date.parse(new Date());
            if (e < Date.parse(new Date(a.start_time))) return void wx.showToast({
                title: "".concat(this.data.plugin_name, "未开始"),
                icon: "none"
            });
            if (e > Date.parse(new Date(a.end_time))) return void wx.showToast({
                title: "".concat(this.data.plugin_name, "已结束"),
                icon: "none"
            });
        }
        wx.navigateTo({
            url: "/packageE/questionnaire/questions/questions?id=" + a.id + "&tag=index"
        });
    },
    tapkey: function(t) {
        console.log(t);
        var a = t.detail.value;
        this.setData({
            _key: a
        }), this.getData();
    },
    back: function(t) {
        wx.navigateBack({
            delta: 1
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (that.data.isloading) {
            var t = that.data.page + 1;
            that.setData({
                page: t
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.questionnaire.api.index.indexInfo");
        t._getNetWork({
            url: e,
            data: {
                index: "index",
                keyword: {
                    title: a.data._key
                },
                page: a.data.page
            },
            success: function(t) {
                var e = t.data;
                console.log(e), 1 == e.result ? (a.setData({
                    list: e.data.index.list.data,
                    current_page: e.data.index.list.current_page,
                    last_page: e.data.index.list.last_page,
                    plugin_name: e.data.plugin_name
                }), a.data.current_page >= a.data.last_page ? a.setData({
                    isloading: !1
                }) : a.setData({
                    isloading: !0
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this, e = t.getNetAddresss("plugin.questionnaire.api.index.indexInfo");
        t._getNetWork({
            url: e,
            data: {
                index: "index",
                keyword: {
                    title: a.data._key
                },
                page: a.data.page
            },
            success: function(t) {
                var e = t.data;
                console.log(e), 1 == e.result ? (a.setData({
                    list: a.data.list.concat(e.data.index.list.data),
                    current_page: e.data.index.list.current_page,
                    last_page: e.data.index.list.last_page
                }), a.data.current_page >= a.data.last_page ? a.setData({
                    isloading: !1
                }) : a.setData({
                    isloading: !0
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});